import '@/scss/reset.scss';
import '@/scss/common.scss';
import '@/css/font-awesome.min.css';
import './cloudhost.scss';
import '@/scss/card.scss';
import '@/scss/select.scss';
import '@/scss/tooltip.scss';
import '@/lib/jRange/jquery.range.scss';
import $ from 'jquery';
import '@/js/tab';
import DiyConfig from './diyConfig';


let btnHref = '/services/server/Order.asp?'
let presetConfig = [
  {
    productid: 'xcloudA',
    CPU: 'IntelXeon E5-2620/5645&times;4',
    Memory: '2 GB',
    HardDisk: '200G SAS硬盘+200G SATA(智能备份)',
    HostID: '创业型云服务器',
    vps: 'okay',
    vr_room: '3'
  }, {
    productid: 'xcloudB',
    CPU: 'IntelXeon E5-2620/5645&times;4',
    Memory: '3 GB',
    HardDisk: '300G SAS硬盘+300G SATA(智能备份)',
    HostID: '发展型云服务器',
    vps: 'okay',
    vr_room: '3'
  }, {
    productid: 'xcloudC',
    CPU: 'IntelXeon E5-2620/5645&times;4',
    Memory: '4 GB',
    HardDisk: '500G SAS硬盘+500G SATA(智能备份)',
    HostID: '舒适型云服务器',
    vps: 'okay',
    vr_room: '3'
  }, {
    productid: 'xcloudD',
    CPU: 'IntelXeon E5-2620/5645&times;4',
    Memory: '6 GB',
    HardDisk: '800G SAS硬盘+800G SATA(智能备份)',
    HostID: '增强型云服务器',
    vps: 'okay',
    vr_room: '3'
  }, {
    productid: 'xcloudE',
    CPU: 'IntelXeon E5-2620/5645&times;4',
    Memory: '8 GB',
    HardDisk: '1T SAS硬盘+1T SATA(智能备份)',
    HostID: '企业型云服务器',
    vps: 'okay',
    vr_room: '3'
  }, {
    productid: 'xcloudF',
    CPU: 'IntelXeon E5-2620/5645&times;4',
    Memory: '1.5 GB',
    HardDisk: '150G SAS硬盘+150G SATA(智能备份)',
    HostID: '普及型云服务器',
    vps: 'okay',
    vr_room: '3'
  }
]
$('[data-plugin="select"]').on('onSelect', function (e) {
  let room = e.value
  let $priceCol = $(this).next('.price-col')
  $priceCol.find('.item').each(function (i, ele) {
    $(ele)[$(ele).data('value') == room ? 'addClass' : 'removeClass']('show')
  })
  let $btn = $(`#${e.selectName}`)
  let params = ''
  for (let item of presetConfig) {
    if (item.productid == e.selectName) {
      item.vr_room = e.value
      for (let key in item) {
        key == 'productid' ? params += `${key}=${escape(item[key])}` : params += `&${key}=${escape(item[key])}`
      }
    }
  }
  $btn.attr('href', btnHref + params)
})
$(document).ready(function () {
  let diyConfig = new DiyConfig(jsonstr)
  diyConfig.init()
})